<?php
require 'makeRequest.php';
session_start();
if($_SESSION['logged_in'] == true){// Just check if the users session thinks it logged in
	// Check with backend so the uid and accesstoken match
	$request = new makeRequest($backend.'login.php?method=validate&id='.$_SESSION['uid'].'&accesstoken='.$_SESSION['accesstoken'], 'GET');
	$request = $request->makeRequest();
	$rbody = $request[0];
	$http_code = $request [1];
	$userobj = json_decode($rbody);
	if($http_code == 200){
		if($userobj[0]->{'valid'} == true){ // If it match
			$isValid = true;

		}else{ // otherwise, force the user to the login page
			$isValid = false;
			header('location: login.php');
		}
	}
}else{
	header('location: login.php');
}
?>